<%@page import="vn.edu.fpt.xml.hrm.pojo.Employee"%>
<%@page import="vn.edu.fpt.xml.hrm.pojo.Project"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.Locale"%>
<%@page import="vn.edu.fpt.xml.hrm.common.FormatUtil"%>
<%@page import="vn.edu.fpt.xml.hrm.pojo.Activity"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Employee approve</title>
<script src="<%=request.getContextPath()%>/js/dateUtil.js"></script>
<script src="<%=request.getContextPath()%>/js/log/log02010.js"></script>
</head>
<body>
	<%
		Set<Activity> actList = null;
		Set<Project> proList = null;
		Set<Employee> empList = null;
		int size = 0;
		String selectedValue = null;
	%>
	<form id="form" action="approve" method="post">
		<div>
			<div>
				<div style="float: left;">
					From date<br />
					To date<br />
					Status
				</div>
				<div>
					<select name="fromYear" id="fromYearSelect"></select>-
					<select name="fromMonth" id="fromMonthSelect"></select>-
					<select name="fromDay" id="fromDaySelect"></select><br />
					<select name="toYear"	id="toYearSelect"></select>-
					<select name="toMonth" id="toMonthSelect"></select>-
					<select name="toDay" id="toDaySelect"></select><br />
					<select name="proId">
						<option value="0">All</option>
						<%
							selectedValue = request.getParameter("proId");
							proList = (Set<Project>) request.getAttribute("proList");
							if (proList != null) {
								for (Project project : proList) {
									if ((project.getId()+"").equals(selectedValue)) {
						%>
						<option value="<%=project.getId()%>" selected="selected" ><%=project.getName()%></option>
						<%
									} else {
						%>
						<option value="<%=project.getId()%>" ><%=project.getName()%></option>
						<%
									}
								}
							}
						%>
					</select><br />
					<select name="empId">
						<option value="0" selected="selected">All</option>
						<%
							selectedValue = request.getParameter("empId");
							empList = (Set<Employee>) request.getAttribute("empList");
							if (empList != null) {
								for (Employee employee : empList) {
									if ((employee.getId()+"").equals(selectedValue)) {
						%>
						<option value="<%=employee.getId()%>"><%=employee.getName()%></option>
						<%
									} else {
						%>
						<option value="<%=employee.getId()%>"><%=employee.getName()%></option>
						<%
									}
								}
							}
						%>
					</select><br />
					<select name="status">
						<option value="">All</option>
						<option value="approved">Approved</option>
						<option value="unapproved">Unapproved</option>
						<option value="rejected">Rejected</option>
					</select>
				</div>
			</div>
			<div>
				<input type="hidden" name="search" value="true"/><input type="submit" name="action" id="btnSearch" value="Search" />
			</div>
		</div>
		<div>
			<table border="1" cellpadding="3">
				<tr>
					<th></th>
					<th>Date</th>
					<th>Description</th>
					<th>Employee</th>
					<th>Project</th>
					<th>Duration</th>
					<th>Status</th>
				</tr>
				<%
					actList = (Set<Activity>) request.getAttribute("actList");
					size = actList.size();
					for (Activity activity : actList) {
				%>
				<tr>
					<td><input type="checkbox" name="selActs" value="<%=activity.getId()%>" /></td>
					<td><%=FormatUtil.formatDate(activity.getDate(),
						"dd/MM/yyyy", Locale.ENGLISH)%></td>
					<td><%=activity.getDescription()%></td>
					<td><%=activity.getEmployee().getName()%></td>
					<td><%=activity.getProject().getName()%></td>
					<td><%=activity.getDuration()%></td>
					<td><%=activity.getStatus()%></td>
				</tr>
				<%
					}
				%>
			</table>
			<input type="submit" name="action" id="btnApprove" value="Approve" />
			<input type="submit" name="action" id="btnReject" value="Reject" />
		</div>
	</form>
</body>
</html>